<?php

 /**
  * @package JooS
  * @subpackage PHPackager
  */

  require_once "JooS/PHPackager/DOM/Node.php";

  require_once "JooS/PHPackager/DOM/Element/Interface.php";

  abstract class JooS_PHPackager_DOM_Element extends JooS_PHPackager_DOM_Node implements JooS_PHPackager_DOM_Element_Interface {
    /**
     * @param string $query
     * @param string $className
     * @return array
     */
    public function query($query, $className = null) {
      $node = $this->getNode();
      $XPath = new DOMXPath($node->ownerDocument);
      $nodesList = $XPath->query($query, $node);

      $queryResult = array();
      for ($i=0; $i<$nodesList->length; $i++) {
        $item = $nodesList->item($i);

        $pkgNode = JooS_PHPackager_DOM_Node::newInstance($item, $this, $className);
        if ($pkgNode) {
          array_push($queryResult, $pkgNode);
        }
      }
      return $queryResult;
    }
  }
